Data Visualization (8-2024)#
Load data#
Show code cell source
import pandas as pd
import sys
sys.path.append('../')
from utils.plots import *
output_notebook()
file_path = '../data/'
model_name = 'AML Epigenomic Risk'
# Read the data
df = pd.read_excel(file_path + 'alma_main_results.xlsx', index_col=0).sort_index()
sig_results = pd.read_excel(file_path + 'signature_results.xlsx', index_col=0).sort_index()
df = df.join(sig_results)
# Define train and test samples
df_train = df[df['Train-Test']=='Train Sample']
df_test = df[df['Train-Test'] == 'Test Sample']
# remove duplicates from the test cohort
df_test = df_test[~df_test['Patient_ID'].duplicated(keep='last')]
# Prognostic model samples
df_px = df[~df['Vital Status at 5y'].isna()]
df_px2 = df_px[df_px['Clinical Trial'].isin(['AAML0531', 'AAML1031', 'AAML03P1'])]
df_px2 = df_px2[df_px2['Sample Type'].isin(
['Diagnosis', 'Primary Blood Derived Cancer - Bone Marrow', 'Primary Blood Derived Cancer - Peripheral Blood'])]
df_px2 = df_px2[~df_px2['Patient_ID'].duplicated(keep='last')]
# drop the samples with missing labels for the ELN AML 2022 Diagnosis
df_dx = df_train[~df_train['WHO 2022 Diagnosis'].isna()]
# exclude the classes with fewer than 5 samples
df_dx = df_dx[~df_dx['WHO 2022 Diagnosis'].isin(['AML with t(9;22); BCR::ABL1'])]
df_px_ = df_px.sort_values(by='P(Death) at 5y').reset_index().reset_index(names=['Percentile']).set_index('index')
df_px_['Percentile'] = df_px_['Percentile'] / len(df_px_['Percentile'])
df2 = df.join(df_px_[['Percentile']])
Interactive atlas#
Show code cell source
from utils.alma_plot import *
plot_alma(df2, save_html=True)
Show code cell output
Show code cell source
from utils.alma_plot2 import *
df_px_ = df_px.sort_values(by='MethylScoreAML').reset_index().reset_index(names=['Percentile']).set_index('index')
df_px_['Percentile'] = df_px_['Percentile'] / len(df_px_['Percentile'])
df3 = df.join(df_px_[['Percentile']])
plot_alma(df3, save_html=False)
Show code cell output
Patient Characteristics#
ALMA (unsupervised)#
Show code cell source
from tableone import TableOne
from datetime import date
columns = ['Hematopoietic Entity','Age (group years)','Sex',
'Clinical Trial',]
mytable_cog = TableOne(df_train.reset_index(), columns,
overall=False, missing=False,
pval=False, pval_adjust=False,
htest_name=True,dip_test=True,
tukey_test=True, normal_test=True,
order={'FLT3 ITD':['Yes','No'],
'Age (group years)':['0-5','5-13','13-39','39-60'],
'MRD 1 Status': ['Positive'],
'Risk Group': ['High Risk', 'Standard Risk'],
'FLT3 ITD': ['Yes'],
'Leucocyte counts (10⁹/L)': ['≥30'],
'Age group (years)': ['≥10']})
mytable_cog.to_excel('../data/pt_characteristics_alma_model_' + str(date.today()) +'.xlsx')
mytable_cog.tabulate(tablefmt="html",
# headers=[score_name,"",'Missing','Discovery','Validation','p-value','Statistical Test']
)
Show code cell output
| Overall | ||
|---|---|---|
| n | 3314 | |
| Hematopoietic Entity, n (%) | Acute lymphoblastic leukemia (ALL) | 700 (28.3) |
| Acute myeloid leukemia (AML) | 1221 (49.4) | |
| Acute promyelocytic leukemia (APL) | 31 (1.3) | |
| Mixed phenotype acute leukemia (MPAL) | 48 (1.9) | |
| Myelodysplastic syndrome (MDS or MDS-like) | 223 (9.0) | |
| Otherwise-Normal (Control) | 251 (10.1) | |
| Age (group years), n (%) | 0-5 | 480 (24.1) |
| 5-13 | 483 (24.2) | |
| 13-39 | 663 (33.2) | |
| 39-60 | 165 (8.3) | |
| 60+ | 203 (10.2) | |
| Sex, n (%) | Female | 885 (49.1) |
| Male | 918 (50.9) | |
| Clinical Trial, n (%) | AAML03P1 | 72 (2.2) |
| AAML0531 | 628 (18.9) | |
| AAML1031 | 587 (17.7) | |
| BM normal AAML0531 | 41 (1.2) | |
| Beat AML Consortium | 316 (9.5) | |
| CCG2961 | 41 (1.2) | |
| CETLAM SMD-09 (MDS-tAML) | 166 (5.0) | |
| French GRAALL 2003–2005 | 141 (4.3) | |
| Japanese AML05 | 64 (1.9) | |
| NOPHO ALL92-2000 | 933 (28.2) | |
| TARGET ALL | 131 (4.0) | |
| TCGA AML | 194 (5.9) |
Fine-tuned (supervised) Dx and Px models#
Show code cell source
columns = ['Age (years)','Age group (years)','Sex','Race or ethnic group',
'Hispanic or Latino ethnic group', 'MRD 1 Status',
'Leucocyte counts (10⁹/L)', 'BM leukemic blasts (%)',
'Risk Group','FLT3 ITD', 'Clinical Trial']
df_test['Age (years)'] = df_test['Age (years)'].astype(float)
# join discovery clinical data with validation clinical data
all_cohorts = pd.concat([df_dx, df_px2, df_test],
axis=0, keys=['Dx Discovery','Px Discovery' ,'Validation'],
names=['cohort']).reset_index()
# columns = ['Age group (years)','Sex', 'MRD 1 Status',
# 'Leucocyte counts (10⁹/L)',
# 'Risk Group','FLT3 ITD', 'Treatment Arm','Clinical Trial']
mytable_cog = TableOne(all_cohorts, columns,
overall=False, missing=False,
pval=False, pval_adjust=False,
htest_name=True,dip_test=True,
tukey_test=True, normal_test=True,
order={'FLT3 ITD':['Yes','No'],
'Race or ethnic group':['White','Black or African American','Asian'],
'MRD 1 Status': ['Positive'],
'Risk Group': ['High Risk', 'Standard Risk'],
'FLT3 ITD': ['Yes'],
'Leucocyte counts (10⁹/L)': ['≥30'],
'Age group (years)': ['≥10']},
groupby='cohort')
mytable_cog.to_excel('../data/pt_characteristics_fine-tuned_models_' + str(date.today()) +'.xlsx')
mytable_cog.tabulate(tablefmt="html",
# headers=[score_name,"",score_name,'Validation','p-value','Statistical Test']
)
Show code cell output
| Dx Discovery | Px Discovery | Validation | ||
|---|---|---|---|---|
| n | 2471 | 946 | 200 | |
| Age (years), mean (SD) | 19.2 (19.7) | 9.4 (6.3) | 8.8 (6.0) | |
| Age group (years), n (%) | ≥10 | 528 (47.4) | 463 (48.9) | 95 (48.0) |
| <10 | 586 (52.6) | 483 (51.1) | 103 (52.0) | |
| Sex, n (%) | Female | 711 (50.5) | 468 (49.5) | 86 (43.0) |
| Male | 697 (49.5) | 478 (50.5) | 114 (57.0) | |
| Race or ethnic group, n (%) | White | 1064 (80.5) | 697 (79.1) | 142 (71.7) |
| Black or African American | 131 (9.9) | 102 (11.6) | 32 (16.2) | |
| Asian | 65 (4.9) | 43 (4.9) | 1 (0.5) | |
| American Indian or Alaska Native | 7 (0.5) | 5 (0.6) | ||
| Other | 48 (3.6) | 28 (3.2) | 21 (10.6) | |
| Pacific Islander | 7 (0.5) | 6 (0.7) | 2 (1.0) | |
| Hispanic or Latino ethnic group, n (%) | Hispanic or Latino | 209 (19.6) | 185 (20.2) | 25 (12.6) |
| Not Hispanic or Latino | 858 (80.4) | 731 (79.8) | 173 (87.4) | |
| MRD 1 Status, n (%) | Positive | 284 (29.6) | 260 (31.5) | 76 (40.4) |
| Negative | 675 (70.4) | 566 (68.5) | 112 (59.6) | |
| Leucocyte counts (10⁹/L), n (%) | ≥30 | 579 (52.4) | 467 (49.4) | 87 (43.7) |
| <30 | 526 (47.6) | 479 (50.6) | 112 (56.3) | |
| BM leukemic blasts (%), mean (SD) | 65.7 (24.1) | 63.8 (24.5) | 60.2 (25.6) | |
| Risk Group, n (%) | High Risk | 198 (14.2) | 129 (13.8) | 51 (25.5) |
| Standard Risk | 628 (45.0) | 454 (48.7) | 86 (43.0) | |
| Low Risk | 570 (40.8) | 349 (37.4) | 63 (31.5) | |
| FLT3 ITD, n (%) | Yes | 180 (16.2) | 165 (17.5) | 31 (15.7) |
| No | 932 (83.8) | 779 (82.5) | 167 (84.3) | |
| Clinical Trial, n (%) | AAML03P1 | 62 (2.5) | 36 (3.8) | |
| AAML0531 | 517 (20.9) | 507 (53.6) | ||
| AAML1031 | 495 (20.0) | 403 (42.6) | ||
| BM normal AAML0531 | 41 (1.7) | |||
| Beat AML Consortium | 192 (7.8) | |||
| CCG2961 | 31 (1.3) | |||
| CETLAM SMD-09 (MDS-tAML) | 166 (6.7) | |||
| French GRAALL 2003–2005 | 141 (5.7) | |||
| Japanese AML05 | 9 (0.4) | |||
| NOPHO ALL92-2000 | 641 (25.9) | |||
| TARGET ALL | 56 (2.3) | |||
| TCGA AML | 120 (4.9) | |||
| AML02 | 158 (79.0) | |||
| AML08 | 42 (21.0) |
By prognostic group#
Discovery#
AML Epigenomic Risk
Show code cell source
def pt_characteristics_by_model(df, model_name, traintest = 'discovery'):
columns = ['Age (years)','Age group (years)','Sex','Race or ethnic group',
'Hispanic or Latino ethnic group', 'MRD 1 Status',
'Leucocyte counts (10⁹/L)', 'BM leukemic blasts (%)',
'Risk Group', 'Clinical Trial','FLT3 ITD', 'Treatment Arm']
mytable_cog = TableOne(df, columns,
overall=False, missing=False,
pval=True, pval_adjust=False,
htest_name=True,dip_test=True,
tukey_test=True, normal_test=True,
order={'FLT3 ITD':['Yes','No'],
'Race or ethnic group':['White','Black or African American','Asian'],
'MRD 1 Status': ['Positive'],
'Risk Group': ['High Risk', 'Standard Risk'],
'FLT3 ITD': ['Yes'],
'Leucocyte counts (10⁹/L)': ['≥30'],
'Age group (years)': ['≥10']},
groupby=model_name)
mytable_cog.to_excel('../data/pt_characteristics_'+ model_name +'_' + traintest + '_' + str(date.today()) + '.xlsx')
return(mytable_cog.tabulate(tablefmt="html",
headers=[model_name + ' ' + traintest,"",'High','Low','p-value','Statistical Test']))
pt_characteristics_by_model(df_px2, model_name, 'Discovery')
Show code cell output
| AML Epigenomic Risk Discovery | High | Low | p-value | Statistical Test | |
|---|---|---|---|---|---|
| n | 453 | 493 | |||
| Age (years), mean (SD) | 8.4 (6.5) | 10.4 (6.0) | <0.001 | Two Sample T-test | |
| Age group (years), n (%) | ≥10 | 193 (42.6) | 270 (54.8) | <0.001 | Chi-squared |
| <10 | 260 (57.4) | 223 (45.2) | |||
| Sex, n (%) | Female | 226 (49.9) | 242 (49.1) | 0.856 | Chi-squared |
| Male | 227 (50.1) | 251 (50.9) | |||
| Race or ethnic group, n (%) | White | 332 (78.7) | 365 (79.5) | 0.424 | Chi-squared (warning: expected count < 5) |
| Black or African American | 55 (13.0) | 47 (10.2) | |||
| Asian | 18 (4.3) | 25 (5.4) | |||
| American Indian or Alaska Native | 3 (0.7) | 2 (0.4) | |||
| Other | 10 (2.4) | 18 (3.9) | |||
| Pacific Islander | 4 (0.9) | 2 (0.4) | |||
| Hispanic or Latino ethnic group, n (%) | Hispanic or Latino | 87 (19.8) | 98 (20.5) | 0.848 | Chi-squared |
| Not Hispanic or Latino | 352 (80.2) | 379 (79.5) | |||
| MRD 1 Status, n (%) | Positive | 166 (41.5) | 94 (22.1) | <0.001 | Chi-squared |
| Negative | 234 (58.5) | 332 (77.9) | |||
| Leucocyte counts (10⁹/L), n (%) | ≥30 | 203 (44.8) | 264 (53.5) | 0.009 | Chi-squared |
| <30 | 250 (55.2) | 229 (46.5) | |||
| BM leukemic blasts (%), mean (SD) | 65.7 (26.1) | 62.0 (22.9) | 0.027 | Two Sample T-test | |
| Risk Group, n (%) | High Risk | 87 (19.6) | 42 (8.6) | <0.001 | Chi-squared |
| Standard Risk | 330 (74.2) | 124 (25.5) | |||
| Low Risk | 28 (6.3) | 321 (65.9) | |||
| Clinical Trial, n (%) | AAML03P1 | 21 (4.6) | 15 (3.0) | 0.020 | Chi-squared |
| AAML0531 | 222 (49.0) | 285 (57.8) | |||
| AAML1031 | 210 (46.4) | 193 (39.1) | |||
| FLT3 ITD, n (%) | Yes | 87 (19.2) | 78 (15.9) | 0.198 | Chi-squared |
| No | 365 (80.8) | 414 (84.1) | |||
| Treatment Arm, n (%) | Arm A | 114 (46.9) | 144 (48.2) | 0.839 | Chi-squared |
| Arm B | 129 (53.1) | 155 (51.8) |
MethylScoreAML-37CpGs
Show code cell source
pt_characteristics_by_model(df_px2, model_name='MethylScoreAML Categorical', traintest='Discovery')
Show code cell output
| MethylScoreAML Categorical Discovery | High | Low | p-value | Statistical Test | |
|---|---|---|---|---|---|
| n | 473 | 473 | |||
| Age (years), mean (SD) | 8.8 (6.6) | 10.0 (6.0) | 0.004 | Two Sample T-test | |
| Age group (years), n (%) | ≥10 | 213 (45.0) | 250 (52.9) | 0.019 | Chi-squared |
| <10 | 260 (55.0) | 223 (47.1) | |||
| Sex, n (%) | Female | 245 (51.8) | 223 (47.1) | 0.172 | Chi-squared |
| Male | 228 (48.2) | 250 (52.9) | |||
| Race or ethnic group, n (%) | White | 343 (78.5) | 354 (79.7) | 0.132 | Chi-squared (warning: expected count < 5) |
| Black or African American | 60 (13.7) | 42 (9.5) | |||
| Asian | 21 (4.8) | 22 (5.0) | |||
| American Indian or Alaska Native | 2 (0.5) | 3 (0.7) | |||
| Other | 10 (2.3) | 18 (4.1) | |||
| Pacific Islander | 1 (0.2) | 5 (1.1) | |||
| Hispanic or Latino ethnic group, n (%) | Hispanic or Latino | 83 (18.2) | 102 (22.2) | 0.157 | Chi-squared |
| Not Hispanic or Latino | 373 (81.8) | 358 (77.8) | |||
| MRD 1 Status, n (%) | Positive | 157 (38.5) | 103 (24.6) | <0.001 | Chi-squared |
| Negative | 251 (61.5) | 315 (75.4) | |||
| Leucocyte counts (10⁹/L), n (%) | ≥30 | 216 (45.7) | 251 (53.1) | 0.027 | Chi-squared |
| <30 | 257 (54.3) | 222 (46.9) | |||
| BM leukemic blasts (%), mean (SD) | 66.0 (25.4) | 61.6 (23.5) | 0.007 | Two Sample T-test | |
| Risk Group, n (%) | High Risk | 88 (19.0) | 41 (8.8) | <0.001 | Chi-squared |
| Standard Risk | 319 (68.8) | 135 (28.8) | |||
| Low Risk | 57 (12.3) | 292 (62.4) | |||
| Clinical Trial, n (%) | AAML03P1 | 19 (4.0) | 17 (3.6) | 0.529 | Chi-squared |
| AAML0531 | 261 (55.2) | 246 (52.0) | |||
| AAML1031 | 193 (40.8) | 210 (44.4) | |||
| FLT3 ITD, n (%) | Yes | 101 (21.4) | 64 (13.6) | 0.002 | Chi-squared |
| No | 371 (78.6) | 408 (86.4) | |||
| Treatment Arm, n (%) | Arm A | 134 (48.0) | 124 (47.1) | 0.905 | Chi-squared |
| Arm B | 145 (52.0) | 139 (52.9) |
Validation#
AML Epigenomic Risk
Show code cell source
pt_characteristics_by_model(df_test, model_name, 'validation')
Show code cell output
| AML Epigenomic Risk validation | High | Low | p-value | Statistical Test | |
|---|---|---|---|---|---|
| n | 80 | 120 | |||
| Age (years), mean (SD) | 7.4 (6.2) | 9.6 (5.7) | 0.013 | Two Sample T-test | |
| Age group (years), n (%) | ≥10 | 31 (39.2) | 64 (53.8) | 0.063 | Chi-squared |
| <10 | 48 (60.8) | 55 (46.2) | |||
| Sex, n (%) | Female | 34 (42.5) | 52 (43.3) | 1.000 | Chi-squared |
| Male | 46 (57.5) | 68 (56.7) | |||
| Race or ethnic group, n (%) | White | 61 (78.2) | 81 (67.5) | 0.173 | Chi-squared (warning: expected count < 5) |
| Black or African American | 11 (14.1) | 21 (17.5) | |||
| Asian | 1 (1.3) | ||||
| Other | 4 (5.1) | 17 (14.2) | |||
| Pacific Islander | 1 (1.3) | 1 (0.8) | |||
| Hispanic or Latino ethnic group, n (%) | Hispanic or Latino | 13 (16.5) | 12 (10.1) | 0.270 | Chi-squared |
| Not Hispanic or Latino | 66 (83.5) | 107 (89.9) | |||
| MRD 1 Status, n (%) | Positive | 34 (46.6) | 42 (36.5) | 0.224 | Chi-squared |
| Negative | 39 (53.4) | 73 (63.5) | |||
| Leucocyte counts (10⁹/L), n (%) | ≥30 | 31 (39.2) | 56 (46.7) | 0.375 | Chi-squared |
| <30 | 48 (60.8) | 64 (53.3) | |||
| BM leukemic blasts (%), mean (SD) | 65.3 (26.7) | 56.9 (24.5) | 0.037 | Two Sample T-test | |
| Risk Group, n (%) | High Risk | 27 (33.8) | 24 (20.0) | <0.001 | Chi-squared |
| Standard Risk | 46 (57.5) | 40 (33.3) | |||
| Low Risk | 7 (8.8) | 56 (46.7) | |||
| Clinical Trial, n (%) | AML02 | 65 (81.2) | 93 (77.5) | 0.645 | Chi-squared |
| AML08 | 15 (18.8) | 27 (22.5) | |||
| FLT3 ITD, n (%) | Yes | 12 (15.2) | 19 (16.0) | 1.000 | Chi-squared |
| No | 67 (84.8) | 100 (84.0) | |||
| Treatment Arm, n (%) | Arm A | 43 (55.1) | 63 (52.5) | 0.829 | Chi-squared |
| Arm B | 35 (44.9) | 57 (47.5) |
MethylScoreAML-37CpGs
Show code cell source
pt_characteristics_by_model(df_test, model_name='MethylScoreAML Categorical', traintest='Validation')
Show code cell output
| MethylScoreAML Categorical Validation | High | Low | p-value | Statistical Test | |
|---|---|---|---|---|---|
| n | 104 | 96 | |||
| Age (years), mean (SD) | 8.2 (6.3) | 9.4 (5.7) | 0.161 | Two Sample T-test | |
| Age group (years), n (%) | ≥10 | 45 (43.7) | 50 (52.6) | 0.264 | Chi-squared |
| <10 | 58 (56.3) | 45 (47.4) | |||
| Sex, n (%) | Female | 48 (46.2) | 38 (39.6) | 0.427 | Chi-squared |
| Male | 56 (53.8) | 58 (60.4) | |||
| Race or ethnic group, n (%) | White | 74 (72.5) | 68 (70.8) | 0.804 | Chi-squared (warning: expected count < 5) |
| Black or African American | 17 (16.7) | 15 (15.6) | |||
| Asian | 1 (1.0) | ||||
| Other | 9 (8.8) | 12 (12.5) | |||
| Pacific Islander | 1 (1.0) | 1 (1.0) | |||
| Hispanic or Latino ethnic group, n (%) | Hispanic or Latino | 14 (13.6) | 11 (11.6) | 0.832 | Chi-squared |
| Not Hispanic or Latino | 89 (86.4) | 84 (88.4) | |||
| MRD 1 Status, n (%) | Positive | 48 (49.5) | 28 (30.8) | 0.014 | Chi-squared |
| Negative | 49 (50.5) | 63 (69.2) | |||
| Leucocyte counts (10⁹/L), n (%) | ≥30 | 45 (43.7) | 42 (43.8) | 1.000 | Chi-squared |
| <30 | 58 (56.3) | 54 (56.2) | |||
| BM leukemic blasts (%), mean (SD) | 65.2 (26.0) | 54.8 (24.3) | 0.006 | Two Sample T-test | |
| Risk Group, n (%) | High Risk | 34 (32.7) | 17 (17.7) | <0.001 | Chi-squared |
| Standard Risk | 57 (54.8) | 29 (30.2) | |||
| Low Risk | 13 (12.5) | 50 (52.1) | |||
| Clinical Trial, n (%) | AML02 | 81 (77.9) | 77 (80.2) | 0.819 | Chi-squared |
| AML08 | 23 (22.1) | 19 (19.8) | |||
| FLT3 ITD, n (%) | Yes | 20 (19.4) | 11 (11.6) | 0.187 | Chi-squared |
| No | 83 (80.6) | 84 (88.4) | |||
| Treatment Arm, n (%) | Arm A | 56 (54.9) | 50 (52.1) | 0.799 | Chi-squared |
| Arm B | 46 (45.1) | 46 (47.9) |
Kaplan-Meier Plots#
Overall study population#
AML Epigenomic Risk
Show code cell source
for dataset, trial in zip([df_px2, df_test],
['Discovery', 'Validation']):
draw_kaplan_meier(model_name=model_name,
df=dataset,
save_survival_table=False,
save_plot=False,
show_ci=False,
add_risk_counts=False,
trialname=trial,
figsize=(8,8))
Show code cell output
MethylScoreAML-37CpGs
Show code cell source
for dataset, trial in zip([df_px2, df_test],
['Discovery', 'Validation']):
draw_kaplan_meier(model_name='MethylScoreAML Categorical',
df=dataset,
save_survival_table=False,
save_plot=False,
show_ci=False,
add_risk_counts=False,
trialname=trial,
figsize=(8,8))
Show code cell output
Per risk group#
AML Epigenomic Risk
Show code cell source
for dataset, trial in zip([df_px2, df_test], ['Discovery', 'Validation']):
risk_groups = ['High Risk', 'Low Risk', 'Standard Risk']
for risk_group in risk_groups:
draw_kaplan_meier(
model_name=model_name,
df=dataset[dataset['Risk Group'] == risk_group],
save_plot=False,
save_survival_table=False,
add_risk_counts=False,
trialname=f'{trial} {risk_group}',
figsize=(8, 8))
Show code cell output
MethylScoreAML-37CpGs
Show code cell source
for dataset, trial in zip([df_px2, df_test], ['Discovery', 'Validation']):
risk_groups = ['High Risk', 'Low Risk', 'Standard Risk']
for risk_group in risk_groups:
draw_kaplan_meier(
model_name= 'MethylScoreAML Categorical',
df=dataset[dataset['Risk Group'] == risk_group],
save_plot=False,
save_survival_table=False,
add_risk_counts=False,
trialname=f'{trial} {risk_group}',
figsize=(8, 8))
Show code cell output
Per risk group (AAML1831 COG)#
AML Epigenomic Risk
Show code cell source
for dataset, trial in zip([df_px2],['Discovery']):
risk_groups = ['High', 'Low', 'Standard']
for risk_group in risk_groups:
draw_kaplan_meier(
model_name=model_name,
df=dataset[dataset['Risk Group AAML1831'] == risk_group],
save_plot=False,
save_survival_table=False,
add_risk_counts=False,
trialname=f'{trial} {risk_group} Risk',
figsize=(8, 8))
Show code cell output
MethylScoreAML-37CpGs
Show code cell source
for dataset, trial in zip([df_px2],['Discovery']):
risk_groups = ['High', 'Low', 'Standard']
for risk_group in risk_groups:
draw_kaplan_meier(
model_name='MethylScoreAML Categorical',
df=dataset[dataset['Risk Group AAML1831'] == risk_group],
save_plot=False,
save_survival_table=False,
add_risk_counts=False,
trialname=f'{trial} {risk_group} Risk',
figsize=(8, 8))
Show code cell output
Forest Plots#
With MRD 1 and BM blast (%)#
AML Epigenomic Risk
Show code cell source
for dataset, trial in zip([df_px2, df_test], ['Discovery', 'Validation']):
df_ = dataset.copy()
df_['BM leukemic blasts (%)'] = pd.cut(df_['BM leukemic blasts (%)'], bins=[0,50,100], labels=['≤50', '>50'])
df_['AML_Epigenomic_Risk'] = df_['AML Epigenomic Risk']
df_['MethylScoreAML_Categorical'] = df_['MethylScoreAML Categorical']
df_['os_time_5y'] = df_['os.time at 5y']
df_['os_evnt_5y'] = df_['os.evnt at 5y']
df_['efs_time_5y'] = df_['efs.time at 5y']
df_['efs_evnt_5y'] = df_['efs.evnt at 5y']
draw_forest_plot_withBMblast(time='os_time_5y',
event='os_evnt_5y',
df=df_,
trialname=trial,
model_name='AML_Epigenomic_Risk',
save_plot=False)
draw_forest_plot_withBMblast(time='efs_time_5y',
event='efs_evnt_5y',
df=df_,
trialname=trial,
model_name='AML_Epigenomic_Risk',
save_plot=False)
Show code cell output
MethylScoreAML-37CpGs
Show code cell source
for dataset, trial in zip([df_px2, df_test], ['Discovery', 'Validation']):
draw_forest_plot_withBMblast(time='os_time_5y',
event='os_evnt_5y',
df=df_,
trialname=trial,
model_name='MethylScoreAML_Categorical',
save_plot=False)
draw_forest_plot_withBMblast(time='efs_time_5y',
event='efs_evnt_5y',
df=df_,
trialname=trial,
model_name='MethylScoreAML_Categorical',
save_plot=False)
Show code cell output
ROC AUC performance#
Diagnostic Model#
Show code cell source
def process_dataset_for_multiclass_auc(df):
# One hot encode `df_dx['AL Epigenomic Subtype']`
df_dx_dummies = pd.get_dummies(df['WHO 2022 Diagnosis'])
# transform boolean columns to integer
df_dx_dummies = df_dx_dummies.astype(int)
# join the one hot encoded columns with the original dataframe
df_dx_auc = pd.concat([df.iloc[:, -34:-6], df_dx_dummies], axis=1)
return df_dx_auc, df_dx_dummies
df_dx_auc_train, df_dx_dummies_train = process_dataset_for_multiclass_auc(df_dx)
df_dx_auc_cog, df_dx_dummies_cog = process_dataset_for_multiclass_auc(df_px2)
df_dx_auc_test, df_dx_dummies_test = process_dataset_for_multiclass_auc(df_test)
p1 = plot_multiclass_roc_auc(df_dx_auc_train, df_dx_dummies_train.columns, title='Discovery')
p2 = plot_multiclass_roc_auc(df_dx_auc_cog, df_dx_dummies_cog.columns, title='Discovery COG peds AML')
p3 = plot_multiclass_roc_auc(df_dx_auc_test, df_dx_dummies_test.columns, title='Validation')
# Create a gridplot
p = gridplot([
[p1, p2, p3,],
], toolbar_location='above')
show(p)
Show code cell output
Prognostic models#
Discovery#
Show code cell source
df_cat = df_px2[['os.evnt at 5y', 'MethylScoreAML Categorical', 'AML Epigenomic Risk']]
df_cont = df_px2[['os.evnt at 5y', 'MethylScoreAML', 'P(Death) at 5y']]
df_cont = df_cont.rename(columns={'P(Death) at 5y':'AML Epigenomic Risk (PaCMAP-LGBM)',
'MethylScoreAML': 'MethylScoreAML (EWAS-CoxPH)'})
df_cat = df_cat.rename(columns={'AML Epigenomic Risk':'AML Epigenomic Risk (PaCMAP-LGBM)',
'MethylScoreAML Categorical': 'MethylScoreAML (EWAS-CoxPH)'})
risk = df_px2[['Risk Group AAML1831','Risk Group']]
low_high_dict = {'Low': 0, 'Low Risk': 0,
'Standard':0.5, 'Standard Risk': 0.5,
'High': 1, 'High Risk': 1}
risk['Risk Group'] = risk['Risk Group'].map(low_high_dict)
risk['Risk Group AAML1831'] = risk['Risk Group AAML1831'].map(low_high_dict)
df_cat['AML Epigenomic Risk (PaCMAP-LGBM)'] = df_cat['AML Epigenomic Risk (PaCMAP-LGBM)'].map(low_high_dict)
df_cat['MethylScoreAML (EWAS-CoxPH)'] = df_cat['MethylScoreAML (EWAS-CoxPH)'].map(low_high_dict)
df_cont_risk = df_cont.join(risk)
df_cat_risk = df_cat.join(risk)
df_cont_risk = df_cont_risk.fillna(0.5)
df_cat_risk = df_cat_risk.fillna(0.5)
p1 = plot_roc_auc(df_cont_risk, 'os.evnt at 5y',title= 'Continuous (prob. of high risk)')
p2 = plot_roc_auc(df_cat_risk, 'os.evnt at 5y',title= 'Categorical (high-low risk)')
# Create a gridplot
p = gridplot([[p1, p2]], toolbar_location='above')
show(p)
Show code cell output
Validation#
Show code cell source
df_cat = df_test[['os.evnt at 5y', 'MethylScoreAML Categorical', 'AML Epigenomic Risk']]
df_cont = df_test[['os.evnt at 5y', 'MethylScoreAML', 'P(Death) at 5y']]
df_cont = df_cont.rename(columns={'P(Death) at 5y':'AML Epigenomic Risk (PaCMAP-LGBM)',
'MethylScoreAML': 'MethylScoreAML (EWAS-CoxPH)'})
df_cat = df_cat.rename(columns={'AML Epigenomic Risk':'AML Epigenomic Risk (PaCMAP-LGBM)',
'MethylScoreAML Categorical': 'MethylScoreAML (EWAS-CoxPH)'})
risk = df_test[['Risk Group']]
risk['Risk Group'] = risk['Risk Group'].map(low_high_dict)
df_cat['AML Epigenomic Risk (PaCMAP-LGBM)'] = df_cat['AML Epigenomic Risk (PaCMAP-LGBM)'].map(low_high_dict)
df_cat['MethylScoreAML (EWAS-CoxPH)'] = df_cat['MethylScoreAML (EWAS-CoxPH)'].map(low_high_dict)
df_cont_risk_test = df_cont.join(risk)
df_cat_risk_test = df_cat.join(risk)
# Rename `Risk Group` to `Risk Group AML02,08`
df_cont_risk_test = df_cont_risk_test.rename(columns={'Risk Group':'Risk Group AML02-08'})
df_cat_risk_test = df_cat_risk_test.rename(columns={'Risk Group':'Risk Group AML02-08'})
p1 = plot_roc_auc(df_cont_risk_test, 'os.evnt at 5y',title= 'Continuous (prob. of high risk)')
p2 = plot_roc_auc(df_cat_risk_test, 'os.evnt at 5y',title= 'Categorical (high-low risk)')
# Create a gridplot
p = gridplot([[p1, p2]], toolbar_location='above')
show(p)
Show code cell output
Pearson Correlation#
Discovery#
Show code cell source
draw_scatter_pearson(df=df_cont_risk,x='MethylScoreAML (EWAS-CoxPH)', y='AML Epigenomic Risk (PaCMAP-LGBM)',s=20)
df_cont_risk.iloc[:,1:].corr().round(2)
Show code cell output
| MethylScoreAML (EWAS-CoxPH) | AML Epigenomic Risk (PaCMAP-LGBM) | Risk Group AAML1831 | Risk Group | |
|---|---|---|---|---|
| MethylScoreAML (EWAS-CoxPH) | 1.00 | 0.76 | 0.48 | 0.53 |
| AML Epigenomic Risk (PaCMAP-LGBM) | 0.76 | 1.00 | 0.54 | 0.59 |
| Risk Group AAML1831 | 0.48 | 0.54 | 1.00 | 0.62 |
| Risk Group | 0.53 | 0.59 | 0.62 | 1.00 |
Validation#
Show code cell source
draw_scatter_pearson(df=df_cont_risk_test,x='MethylScoreAML (EWAS-CoxPH)', y='AML Epigenomic Risk (PaCMAP-LGBM)',s=20)
df_cont_risk_test.iloc[:,1:].corr().round(2)
Show code cell output
| MethylScoreAML (EWAS-CoxPH) | AML Epigenomic Risk (PaCMAP-LGBM) | Risk Group AML02-08 | |
|---|---|---|---|
| MethylScoreAML (EWAS-CoxPH) | 1.00 | 0.69 | 0.44 |
| AML Epigenomic Risk (PaCMAP-LGBM) | 0.69 | 1.00 | 0.48 |
| Risk Group AML02-08 | 0.44 | 0.48 | 1.00 |
Sankey plots#
Note
Sankey plots below compare the distribution of categories. The width of the lines is proportional to the number of patients in each group.
Samples with annotated diagnosis info#
Show code cell source
colors = get_custom_color_palette()
draw_sankey_plot(df_train, 'WHO 2022 Diagnosis', 'AL Epigenomic Subtype', colors,
title='Discovery cohort', fig_size=(4, 11),
fontsize=8, nan_action='drop')
draw_sankey_plot(df_px2, 'WHO 2022 Diagnosis', 'AL Epigenomic Subtype', colors,
title= 'Discovery cohort (COG peds AML Dx samples only)',fig_size=(4, 10),
fontsize=8, nan_action='drop')
draw_sankey_plot(df_test, 'WHO 2022 Diagnosis', 'AL Epigenomic Subtype', colors,
title= 'Validation cohort',fig_size=(3, 7),
fontsize=8, nan_action='drop')
Show code cell output
Predictions in samples for which no WHO 22 Dx data was available#
Show code cell source
draw_sankey_plot(df_train, 'WHO 2022 Diagnosis', 'AL Epigenomic Subtype', colors,
title='Discovery cohort', fig_size=(4, 9),
fontsize=8, nan_action='keep only')
draw_sankey_plot(df_px2, 'WHO 2022 Diagnosis', 'AL Epigenomic Subtype', colors,
title= 'Discovery cohort (COG peds AML Dx samples only)',fig_size=(4, 8),
fontsize=8, nan_action='keep only')
draw_sankey_plot(df_test, 'WHO 2022 Diagnosis', 'AL Epigenomic Subtype', colors,
title= 'Validation cohort',fig_size=(4, 8),
fontsize=8, nan_action='keep only')
Show code cell output
Reason for unclassified samples#
Show code cell source
draw_sankey_plot(df_train, 'WHO 2022 Diagnosis', 'Primary Cytogenetic Code', colors,
title='Discovery cohort', fig_size=(4, 6),
fontsize=8, nan_action='keep only')
draw_sankey_plot(df_px2, 'WHO 2022 Diagnosis', 'Gene Fusion', colors,
title= 'Discovery cohort (COG peds AML Dx samples only)',fig_size=(4, 9),
fontsize=8, nan_action='keep only')
draw_sankey_plot(df_test, 'WHO 2022 Diagnosis', 'Primary Cytogenetic Code', colors,
title= 'Validation cohort',fig_size=(2, 3),
fontsize=8, nan_action='keep only')
Show code cell output
Risk group comparison in COG#
Show code cell source
draw_sankey_plot(df_px2, 'Risk Group', 'Risk Group AAML1831', colors,
title= 'Discovery cohort (COG peds AML Dx samples only)',fig_size=(2, 4),
fontsize=8, nan_action='drop')
draw_sankey_plot(df_px2, 'Risk Group AAML1831', 'AML Epigenomic Risk', colors,
title= 'Discovery cohort (COG peds AML Dx samples only)',fig_size=(2, 4),
fontsize=8, nan_action='drop')
Show code cell output
Px and Dx model comparison#
Show code cell source
draw_sankey_plot(df_train, 'AML Epigenomic Risk', 'AL Epigenomic Subtype', colors,
title='Discovery cohort', fig_size=(3, 10),
fontsize=8, nan_action='drop')
draw_sankey_plot(df_px2, 'AML Epigenomic Risk', 'AL Epigenomic Subtype', colors,
title= 'Discovery cohort (COG peds AML Dx samples only)',fig_size=(3, 10),
fontsize=8, nan_action='drop')
draw_sankey_plot(df_test, 'AML Epigenomic Risk', 'AL Epigenomic Subtype', colors,
title= 'Validation cohort',fig_size=(3, 8),
fontsize=8, nan_action='drop')
Show code cell output
Performance metrics#
AML Epigenomic Risk#
Show code cell source
plot_confusion_matrix_stacked(df_px2, df_test, 'os.evnt at 5y', 'AML Epigenomic Risk_int','os.evnt at 5y')
Show code cell output
Metrics:
| | Accuracy | Sensitivity | Specificity | Precision | F1-score | AUC-ROC |
|:-----------|-----------:|--------------:|--------------:|------------:|-----------:|----------:|
| Train | 0.705 | 0.757 | 0.676 | 0.565 | 0.647 | 0.717 |
| Validation | 0.7 | 0.667 | 0.714 | 0.5 | 0.571 | 0.69 |
MethylScoreAML#
Show code cell source
plot_confusion_matrix_stacked(df_px2, df_test, 'os.evnt at 5y', 'MethylScoreAML_cat_bin','os.evnt at 5y')
Show code cell output
Metrics:
| | Accuracy | Sensitivity | Specificity | Precision | F1-score | AUC-ROC |
|:-----------|-----------:|--------------:|--------------:|------------:|-----------:|----------:|
| Train | 0.68 | 0.751 | 0.64 | 0.537 | 0.626 | 0.696 |
| Validation | 0.62 | 0.733 | 0.571 | 0.423 | 0.537 | 0.652 |
AL Epigenomic Subtype#
Show code cell source
plot_confusion_matrix_stacked(df_dx, df_test, 'WHO 2022 Diagnosis', 'AL Epigenomic Subtype', 'WHO 2022 Diagnosis', figsize=(22,14))
Show code cell output
Metrics:
| | Accuracy | Macro F1 | Weighted F1 | Cohen's Kappa |
|:-----------|-----------:|-----------:|--------------:|----------------:|
| Train | 0.989 | 0.986 | 0.989 | 0.988 |
| Validation | 0.96 | 0.66 | 0.98 | 0.941 |
Watermark#
Author: Francisco_Marchi@Lamba_Lab_UF
Last updated: 2024-09-11
Python implementation: CPython
Python version : 3.10.13
IPython version : 8.20.0
pandas : 2.2.0
seaborn : 0.13.2
matplotlib: 3.8.2
tableone : 0.8.0
sklearn : 1.4.0
lifelines : 0.28.0
Compiler : GCC 11.4.0
OS : Linux
Release : 5.15.133.1-microsoft-standard-WSL2
Machine : x86_64
Processor : x86_64
CPU cores : 32
Architecture: 64bit
Git repo: git@github.com:f-marchi/ALMA.git